import 'package:color_dart/color_dart.dart';
import 'package:flutter/material.dart';
import 'package:fluttertz/components/a_row/a_row.dart';
import 'package:fluttertz/jsonserialize/tzuser/data.dart';
import 'package:fluttertz/utils/Icon.dart';
import 'package:fluttertz/utils/global.dart';

class Mine extends StatefulWidget {
  static _MineState _mineState;

  getAppBar() => _mineState.createAppBar();

  Mine() {
    _mineState = _MineState();
  }

  _MineState createState() => _MineState();
}

class _MineState extends State<Mine> {
  AppBar createAppBar() {
    return null;
  }

  @override
  Widget build(BuildContext context) {
    return Container(
        decoration: BoxDecoration(
            image: DecorationImage(
          image: AssetImage("lib/assets/images/tz/bg.png"),
          fit: BoxFit.cover,
        )),
        child: Scaffold(
            backgroundColor: Colors.transparent,
            body: Column(
              children: <Widget>[
                Container(
                  color: Colors.transparent,
                  padding: EdgeInsets.symmetric(horizontal: 0),
                  child: Column(
                    children: <Widget>[
                      Container(
                        alignment: Alignment.centerLeft,
                        height: 220,
                        color: Colors.transparent,
                        padding: EdgeInsets.only(left: 20, right: 20, top: 44),
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children: <Widget>[
                            Container(
                                alignment: Alignment.centerRight,
                                margin: EdgeInsets.only(bottom: 20),
                                child: icontupian18(
                                    size: 24, color: rgba(255, 255, 255, .9))),
                            buildUser(),
                          ],
                        ),
                      ),
                      ARow(
                        height: 60,
                        padding: EdgeInsets.all(0),
                        color: hex('#11fdf6e9'),
                        borderRadius: BorderRadius.all(Radius.circular(0)),
                        border: new Border.all(width: 0.5, color: rgba(53, 53, 53, 0.5)),
                        leftChild: Container(
                            color: Colors.transparent,
                            width: 40,
                            alignment: Alignment.centerLeft,
                            child: iconzhzx(
                                color: hex('#ccfdf6e9'), size: 20)),
                        centerChild:
                            Text('賬號資訊', style: TextStyle(backgroundColor: Colors.transparent, fontSize: 16)),
                        rightChild: icontupian6(
                            color: rgba(228, 228, 228, 1), size: 14),
                        onPressed: () => G.pushNamed('/zhzx'),
                      ),
                      ARow(
                        height: 60,
                        padding: EdgeInsets.all(0),
                        color: hex('#11fdf6e9'),
                        borderRadius: BorderRadius.all(Radius.circular(0)),
                        border: new Border.all(width: 0.1, color: rgba(53, 53, 53, 0.5)),
                        leftChild: Container(
                          width: 40,
                          alignment: Alignment.centerLeft,
                          child: Container(
                              padding: EdgeInsets.only(left:8),
                              child: iconcjwt(
                                  color: hex('#ccfdf6e9'), size: 20)),
                        ),
                        centerChild:
                            Text('常見問題', style: TextStyle(fontSize: 16)),
                        rightChild: icontupian6(
                            color: rgba(228, 228, 228, 1), size: 14),
                        onPressed: () => G.pushNamed('/cjwt'),
                      ),
                      ARow(
                        height: 60,
                        padding: EdgeInsets.all(0),
                        color: hex('#11fdf6e9'),
                        borderRadius: BorderRadius.all(Radius.circular(0)),
                        border: new Border.all(width: 0.5, color: rgba(53, 53, 53, 0.5)),
                        leftChild: Container(
                          width: 40,
                          alignment: Alignment.centerLeft,
                          child: Container(
                              child: iconwtfk(
                                  color: hex('#ccfdf6e9'), size: 20)),
                        ),
                        centerChild:
                            Text('問題反饋', style: TextStyle(fontSize: 16)),
                        rightChild: icontupian6(
                            color: rgba(228, 228, 228, 1), size: 14),
                        onPressed: () => G.pushNamed('/wtfk'),
                      ),
                    ],
                  ),
                ),
              ],
            )));
  }

  ARow buildUser() {
    TzUserData userData = G.user.data;

    return ARow(
      height: 85,
      color: Colors.transparent,
      border: new Border.all(width: 1, color: Colors.transparent),
      padding: EdgeInsets.all(0),
      leftChild: ClipRRect(
          borderRadius: new BorderRadius.circular(27),
          child: Image.asset(
            'lib/assets/images/logo.png',
            width: 80,
            height: 80,
            fit: BoxFit.cover,
          )),
      centerChild: Container(
        margin: EdgeInsets.only(left: 10),
        child: Text(
          userData == null ? '賬號' : userData.username,
          style: TextStyle(
              color: rgba(255, 255, 255, 1),
              fontSize: 22,
              fontWeight: FontWeight.bold),
        ),
      ),
    );
  }
}
